

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

import javax.xml.parsers.DocumentBuilder;  
import javax.xml.parsers.DocumentBuilderFactory;  
  
import org.w3c.dom.Document;  
import org.w3c.dom.Element;  
import org.w3c.dom.NodeList;  
import org.w3c.dom.Node;  

public class SyncController {

	public static void main(String[] args) throws Exception{
		File file = new File("D:\\java exam directory\\workspace_local\\demo\\src\\main\\java\\com\\script\\sync\\build.xml");
		InputStream in = null;
        in = new FileInputStream(file);
			
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();  
        DocumentBuilder builder = factory.newDocumentBuilder();  
        Document document = builder.parse(in);  
        Element element = document.getDocumentElement(); 
        
        NodeList nodes = element.getElementsByTagName("result");          
        //System.out.println(nodes.getLength());
        Node successNode = nodes.item(0);         
        /*System.out.println(successNode.getNodeName());
        System.out.println(successNode.getNodeValue());
        System.out.println(successNode.getFirstChild().getNodeName());*/
        //System.out.println(successNode.getFirstChild().getNodeValue());
        
        //NodeList childNodes = successNode.getChildNodes();  
        //System.out.println(successNode.getNodeValue());
        //System.out.println(childNodes.item(0).getFirstChild().getNodeValue());
        
        if ("SUCCESS".equals(successNode.getFirstChild().getNodeValue())){
        	Runtime rt = Runtime.getRuntime();
        	//rt.exec("D:");
        	//Process proc = rt.exec("D:\\java exam directory\\workspace_local\\demo\\src\\main\\java\\com\\script\\sync\\a.bat");
        	Process proc = rt.exec("a.");
        	//System.out.println("111111111111111111");
        }
	}

}
